package com.nuoniu.sibanyun.service.erp.in.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.nuoniu.sibanyun.entity.erp.in.InUnitGroup;
import com.nuoniu.sibanyun.mapper.erp.in.InUnitGroupMapper;
import com.nuoniu.sibanyun.service.erp.IErpAccountService;
import com.nuoniu.sibanyun.service.erp.in.IInUnitGroupService;
import com.nuoniu.sibanyun.userThread.UserInfo;
import com.nuoniu.sibanyun.userThread.UserThreadLocal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 计量单位分组 服务实现类
 * </p>
 *
 * @author baiqiang
 * @since 2020-09-25
 */
@Service
public class InUnitGroupServiceImpl extends ServiceImpl<InUnitGroupMapper, InUnitGroup> implements IInUnitGroupService {

    @Autowired
    private IErpAccountService accountService;

    @Override
    public List<InUnitGroup> getUnitGroupList() {
        UserInfo userInfo = UserThreadLocal.get();
        Integer accountId = accountService.getCurrentAccountId();
        return baseMapper.getUnitGroupList(userInfo.getCompanyId(), accountId);
    }

    @Override
    public InUnitGroup getByName(String unitGroupName) {
        return baseMapper.getByName(unitGroupName, UserThreadLocal.get().getCompanyId());
    }

    @Override
    public InUnitGroup getByCode(String code) {
        return baseMapper.getByCode(code, UserThreadLocal.get().getCompanyId());
    }
}
